<?php

namespace app\admin\controller\bot;

use app\common\controller\AdminController;
use app\common\services\annotation\ControllerAnnotation;
use app\common\services\annotation\NodeAnnotation;

use support\Request; //请求类
use support\Response; //请求类
use think\facade\Db; //数据库类
use think\App; //初始化
use think\Exception; //异常
/**
 * @ControllerAnnotation(title="bot_log")
 */
class LogController extends AdminController
{

    public function initialize()
    {
        parent::initialize();
        $this->model = new \app\admin\model\BotLog();
    }

    public function index(Request $request): Response{
        $gfid = $request->get('id');
        if(!$gfid){
           $gfid = "-1" ;
        }
        if (!$request->isAjax()) return view('admin/bot/log/index',['gfid'=>$gfid]);
        if ($request->input('selectFields')) {
            return $this->selectList();
        }
        list($page, $limit, $where) = $this->buildTableParams();
        $count = $this->model->where($where)->count();
        $list  = $this->model->where($where)->order($this->order)->page($page, $limit)->select()->toArray();
        $data  = [
            'code'  => 0,
            'msg'   => '',
            'count' => $count,
            'data'  => $list,
        ];
        return json($data);
    }
}
